﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Warehouse.Core;
using Tanmia.Basis.Domain;
using Tanmia.Basis.Data;
using Tanmia.Basis;

namespace Tanmia.Warehouse.Domain
{
    public class StorageSectionDomain : BaseDomainObject<StorageSection>
    {
        public StorageSectionDomain(ISessionManager sessionManager)
            : base(sessionManager)
        {
        }

        public IList<StorageSection> Get(Branch branch)
        {
            return Gets(new BranchStorageSpecs(branch));
        }
    }

    public class BranchStorageSpecs : Specification<StorageSection>
    {
        private Branch branch;

        public BranchStorageSpecs(Branch branch)
        {
            this.branch = branch;    
        }

        public override System.Linq.Expressions.Expression<Func<StorageSection, bool>> IsSatisfiedBy()
        {
            return x => x.Branch.BranchID == branch.BranchID;
        }
    }
}
